﻿using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using WJSHWebApi.DBModel;
using WJSHWebApi.InterFace;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WJSHWebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ZJFL : ControllerBase
    {
        IDBInterface iDBInterface;
        public ZJFL(IDBInterface dBInterface)
        {
            iDBInterface = dBInterface;
        }
        // GET: api/<ZJFL>
        [HttpGet]
        public IEnumerable<ZJFLTLD_Cache_Entity> GetZJFLCacheslist()
        {

            return iDBInterface.Where<ZJFLTLD_Cache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == true);
        }

        [HttpGet]
        public ZJFLTLD_Cache_Entity GetZJFLTLCache_EntityByRemark(string Remark)
        {

            return iDBInterface.FirstOrDefault<ZJFLTLD_Cache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.Remark == Remark);
        }


        [HttpGet]
        public ZJFLTLD_Entity GetZJFLTL_EntityByRemark(string Remark)
        {

            return iDBInterface.FirstOrDefault<ZJFLTLD_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.Remark == Remark);
        }

        [HttpGet]
        public IEnumerable<ZJFLTLD_Entity> GetZJFLlist()
        {

            return iDBInterface.Where<ZJFLTLD_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == false);
        }

        [HttpGet]
        public IEnumerable<ZJFLTLD_Cache_Entity> GetZJFLCacheslistEmpty()
        {
            return iDBInterface.Where<ZJFLTLD_Cache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == false);
        }


        [HttpGet]
        public IEnumerable<ZJFLTLD_Entity> GetZJFLlistEmpty()
        {

            return iDBInterface.Where<ZJFLTLD_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == true);
        }

        [HttpGet]
        public ZJFLCache_Entity GetZJFLCache_EntityByRemark(string Remark)
        {

            return iDBInterface.FirstOrDefault<ZJFLCache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.Remark == Remark);
        }

        [HttpGet]
        public bool UpdataNoHave(string Remark)
        {
            var ZJFLCache_Entity = iDBInterface.FirstOrDefault<ZJFLCache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            ZJFLCache_Entity.IsHave = false;
            return iDBInterface.Update(ZJFLCache_Entity);
        }
        [HttpGet]
        public bool UpdataHave(string Remark)
        {
            var ZJFLCache_Entity = iDBInterface.FirstOrDefault<ZJFLCache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            ZJFLCache_Entity.IsHave = true;
            return iDBInterface.Update(ZJFLCache_Entity);
        }



        [HttpGet]
        public bool UpdataNoHaveZJFLTLDCache(string Remark)
        {
            var ZJFLTLD_Cache_Entity = iDBInterface.FirstOrDefault<ZJFLTLD_Cache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            ZJFLTLD_Cache_Entity.IsHave = false;
            return iDBInterface.Update(ZJFLTLD_Cache_Entity);
        }
        [HttpGet]
        public bool UpdataHaveZJFLTLDCache(string Remark)
        {
            var ZJFLTLD_Cache_Entity = iDBInterface.FirstOrDefault<ZJFLTLD_Cache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            ZJFLTLD_Cache_Entity.IsHave = true;
            return iDBInterface.Update(ZJFLTLD_Cache_Entity);
        }
        [HttpGet]
        public bool UpdataNoHaveZJFLTLD(string Remark)
        {
            var ZJFLTLD_Entity = iDBInterface.FirstOrDefault<ZJFLTLD_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            ZJFLTLD_Entity.IsHave = false;
            return iDBInterface.Update(ZJFLTLD_Entity);
        }
        [HttpGet]
        public bool UpdataHaveZJFLTLD(string Remark)
        {
            var ZJFLTLD_Entity = iDBInterface.FirstOrDefault<ZJFLTLD_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            ZJFLTLD_Entity.IsHave = true;
            return iDBInterface.Update(ZJFLTLD_Entity);
        }
    }
}
